<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{css/layui.css}"  media="all">
    <script th:src="@{layui.js}"></script>
</head>
<body>
<div class="layui-upload">
    <button type="button" class="layui-btn layui-btn-normal" id="test8">选择文件</button>
    <button type="button" class="layui-btn" id="test9">开始上传</button>
</div>

<script>
    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;

        // upload.render({ //允许上传的文件后缀
        //     elem: '#test9'
        //     ,url: '/upload/'
        //     ,accept: 'file' //普通文件
        //     ,exts: 'docx|doc|xlsx|' //只允许上传压缩文件
        //     ,done: function(res){
        //         console.log(res)
        //     }
        // });

        //设定文件大小限制
        // upload.render({
        //     elem: '#test9'
        //     ,url: '/upload/'
        //     ,size: 60 //限制文件大小，单位 KB
        //     ,done: function(res){
        //         console.log(res)
        //     }
        // });

        upload.render({
            elem: '#test8'
            ,url: 'upload-contract'
            ,auto: false
            // ,multiple: true
            ,bindAction: '#test9'
            ,done: function(res){
                debugger
                console.log(res)
            },
            error:function(res){
                alert(res)
            }
        });

    });
</script>
</body>
</html>